﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using WebUI.ReportServer_wsdl;

namespace WebUI.Pages
{
    public partial class mgrReports : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UserController usrController = new UserController();
            int idUsuario = usrController.GetUserID(User.Identity.Name);
            int idTeam = usrController.GetUserTeamID(idUsuario);

            if (idTeam != 9)
            {
                Response.Redirect("../Pages/403.aspx");
            }
            if (!this.IsPostBack)
            {
                ReportingService2010 reportsrv = new ReportingService2010();
                reportsrv.Credentials = System.Net.CredentialCache.DefaultCredentials;
                CatalogItem[] reports = reportsrv.ListChildren("/Solutions", false);
                for (int i = 0; i < reports.Length; i++)
                    ddlReport.Items.Add(reports[i].Name.ToString());
                
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ReportViewer1.ServerReport.ReportPath = "/Solutions/" + ddlReport.SelectedItem.ToString();
            ReportViewer1.DataBind();
        }
    }
}